import Vue from 'vue'
import Router from 'vue-router'
import Routes from './routes'

Vue.use(Router)

const router = new Router({
 // mode: 'history',
  routes: Routes
})

const title = '首页 - 四川科瑞软件有限责任公司'

router.beforeEach((to, from, next) => {
  let titleStr = ''
  if (to.name !== 'home') {
    for (let i = to.matched.length - 1; i >= 0; i--) {
      titleStr += `${to.matched[i].meta.title} -`
    }
  }
  titleStr += title
  document.title = titleStr
  next()
})

export default router
